﻿

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>修改特体值</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
</head>
<body>
    <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 0 0 0;">
        <div class="layui-form-item">
            <label class="layui-form-label">部位名称</label>
            <div class="layui-input-inline">
                <input type="text" name="bwname" id="bwname" lay-verify="required" placeholder="请输入部位名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">部位简称</label>
            <div class="layui-input-inline">
                <input type="text" name="bwothername" id="bwothername" placeholder="部位简称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">部位描述</label>
            <div class="layui-input-inline">
                <input type="text" name="bwremark" id="bwremark" placeholder="部位描述" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">公差</label>
            <div class="layui-input-inline">
                <input type="text" name="publicerrand" id="publicerrand" onblur="check_one(this)" placeholder="请输入特体最大值" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最大值</label>
            <div class="layui-input-inline">
                <input type="text" name="sbmaxvalue" id="sbmaxvalue" onblur="check_szAndone(this)" placeholder="请输入特体最大值" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最小值</label>
            <div class="layui-input-inline">
                <input type="text" name="sbminvalue" id="sbminvalue" onblur="check_szAndone(this)" placeholder="请输入特体最小值" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">序号</label>
            <div class="layui-input-inline">
                <input type="text" name="sbxh" id="sbxh" placeholder="请输入序号"  onblur="check_zzs(this)"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否可用</label>
            <div class="layui-input-block">
                <input type="checkbox" id="isactive" checked="" name="open" lay-skin="switch" lay-filter="component-form-switchTest" lay-text="可用|禁用">
            </div>
        </div>
        <div style="padding-bottom: 10px;text-align:center">
            <button class="layui-btn layuiadmin-btn-useradmin" data-type="add" id="LAY-user-front-submit">确认</button>
        </div>
    </div>

    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/js/jquery.min2.1.4.js"></script>
    <script src="../../../layuiadmin/js/jshelp.js"></script>
    <script>
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(decodeURI(r[2])); return null; //返回参数值
        }
        var editid = getUrlParam('editid');
        //加载数据
        $.ajax({
            url: 'ashx/list.ashx?type=getlist_byid&editid=' + editid,
            type: 'GET',
            success: function (data) {
                var str = "";
                for (var i = 0; i < data.data.length; i++) {
                    $("#bwname").val(data.data[i].bwname);
                    $("#bwothername").val(data.data[i].bwothername);
                    $("#bwremark").val(data.data[i].bwremark);
                    $("#publicerrand").val(data.data[i].publicerrand);
                    $("#sbmaxvalue").val(data.data[i].maxvalue);
                    $("#sbminvalue").val(data.data[i].minvalue);
                    $("#sbxh").val(data.data[i].xh);
                    if (data.data[i].isactive == 'Y') {
                        $("#isactive").attr("checked", "checked");
                        $("#isactive").attr("value", '可用');
                    }
                    else {
                        $("#isactive").removeAttr("checked");
                        var x = document.getElementsByClassName("layui-unselect layui-form-switch layui-form-onswitch");
                        x[0].setAttribute("class", "layui-unselect layui-form-switch");
                        var d = document.getElementsByTagName('em')[0];
                        d.firstChild.nodeValue = '禁用';
                    }

                }

            }
        })

        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'upload'], function () {
            var $ = layui.$
                , form = layui.form
                , upload = layui.upload;
            //提交
            $("#LAY-user-front-submit").on('click', function () {
                var bwname = $("#bwname").val();
                var bwothername = $("#bwothername").val();
                var bwremark = $("#bwremark").val();
                var publicerrand = $("#publicerrand").val();
                var sbmaxvalue = $("#sbmaxvalue").val();
                var sbminvalue = $("#sbminvalue").val();
                var sbxh = $("#sbxh").val();
                var isactive = $("#isactive").prop("checked");
                var arr = new Array();
                if (bwname == "" || bwname == null || bwname == undefined) {
                    layer.msg('请填写部位名称', { icon: 5 });
                    return;
                }
                if (bwothername == "" || bwothername == null || bwothername == undefined) {
                    layer.msg('请填写部位简称', { icon: 5 });
                    return;
                }
                if (publicerrand == "" || publicerrand == null || publicerrand == undefined) {
                    layer.msg('请填写公差', { icon: 5 });
                    return;
                }
                if (sbmaxvalue == "" || sbmaxvalue == null || sbmaxvalue == undefined) {
                    layer.msg('请填写最大值', { icon: 5 });
                    return;
                }
                if (sbminvalue == "" || sbminvalue == null || sbminvalue == undefined) {
                    layer.msg('请填写最小值', { icon: 5 });
                    return;
                }
                if (bwname != "") {
                    var add = {
                        "id": editid,
                        "bwname": bwname,
                        "bwothername": bwothername,
                        "bwremark": bwremark,
                        "publicerrand": publicerrand,
                        "sbmaxvalue": sbmaxvalue,
                        "sbminvalue": sbminvalue,
                        "sbxh": sbxh,
                        "isactive": isactive
                    };
                    arr.push(add);
                    $.ajax({
                        url: 'ashx/list.ashx?type=edit',
                        type: "post",
                        contentType: "application/json",
                        dataType: "json",
                        data: JSON.stringify({ 'LoadData_type': arr }),
                        success: function (res) {
                            var index = parent.layer.getFrameIndex(window.name);
                            if (res.flag == "True") {
                                layer.msg(res.remsg, {
                                    time: 2000,
                                    end: function () {
                                        parent.layer.close(index);
                                        window.parent.location.reload();
                                    }
                                })
                            }
                            else {
                                layer.alert(res.remsg);
                            }
                        }
                    })
                }
            });
        })
    </script>
</body>
</html>